package com.yl.constant;

public class Const {

    // 配置文件相关
    public static final String APP_NAME = "app.name";
    public static final String APP_ENV = "app.env";
    public static final String CFG_DEFAULT = "app.properties";
    public static final String CFG_ENV_TPL = "app-{}.properties";


    // punctuation[ptn][标点]
    public static final String PTN_LF = "\n";
    public static final String PTN_EMPTY = "";
    public static final String PTN_SPACE = " ";
    public static final String PTN_COMMA = ",";
    public static final String PTN_COLON = ":";
    public static final String PTN_SLASH = "/";
    public static final String PTN_PERIOD = ".";
    public static final String PTN_PERIOD_REGX = "\\.";
    public static final String PTN_ASTERISK = "*";
    public static final String PTN_BAR_MID = "-";
    public static final String PTN_BAR_BOTTOM = "_";
    // format[fmt][格式]
    private static final String FMT_DOUBLE = "%.nf";
    public static final String FMT_STD_MON = "yyyy-MM";
    public static final String FMT_STD_DAY = "yyyy-MM-dd";
    public static final String FMT_STD_HOU = "yyyy-MM-dd HH";
    public static final String FMT_STD_MIN = "yyyy-MM-dd HH:mm";
    public static final String FMT_STD_SEC = "yyyy-MM-dd HH:mm:ss";
    public static final String FMT_TRIM_DAY = "yyyyMMdd";
    public static final String FMT_TRIM_SEC = "yyyyMMddHHmmss";
    public static final String FMT_TRIM_MILLI = "yyyyMMddHHmmssSSS";
    public static final String FMT_STD_MILLI = "yyyy-MM-dd HH:mm:ss.SSS";
    // string[str][字符或字符串]
    public static final String S_ZERO = "0";
    public static final String S_OP = "op";
    public static final String S_NULL = "null";
    public static final String S_DATA = "data";
    public static final String S_COUNT_CAL_ST = "count-cal-start-time";
    public static final String S_COUNT_CAL_ET = "count-cal-end-time";
    public static final String S_PAYLOAD_STA = "payload-state";
    public static final String S_CONFIG_STA = "config-state";
    public static final String S_STATUS_ONLINE = "status-online";
    public static final String S_CACHE_RECEIVE = "cache-receive";
    public static final String S_TAG_CAL = "tag-cal";
    public static final String S_TIMER_SET = "timer-set";
    public static final String S_COUNT = "count";
    public static final String S_AFTER = "after";
    public static final String S_TABLE = "table";
    public static final String S_CALK = "calk";
    public static final String S_SOURCE = "source";
    public static final String S_RABBITMQ = "rabbitmq";
    public static final String S_KAFKA = "kafka";
    public static final String S_INFLUXDB = "influxdb";
    public static final String S_TDENGINE = "tdengine";
    public static final String S_ALL = "all";
    public static final String S_TID = "tid";
    public static final String S_KAFKA_SOURCE = "kafka-source";
    public static final String S_MYSQL_CDC_JOB = "mysql-cdc-job";
    public static final String TEL_RC = "+86";
    public static final String SUFFIX_CSV = ".csv";
    public static final String SUFFIX_ZIP = ".zip";
    // template[tpl][字符串模板]
    public static final String TPL_TBL_RAW = "{}_raw";
    public static final String TPL_TBL_CAL = "{}_cal";
    public static final String TPL_TBL_COUNT = "{}_count";
    //    public static final String TPL_TBL_CAL = "{}_{}";
    public static final String TPL_FIELD = "v{}";
    public static final String TPL_STA_TARGET = "target-{}";
    public static final String TPL_STA_TYPE = "type-{}";
    public static final String TPL_WARN_MSG = "{}项目{}预警：测点编号为{}，预警指标为{}，测点类型为{}，预警时间为{}，" +
            "预警值为{}，阈值范围为{}到{}，请登录系统及时处理！";


    // flink
    public static final String FLINK_SOURCE = "flink.source";
    public static final String FLINK_SINK = "flink.sink";
    public static final String FLINK_RECOVERY_DIR = "flink.recovery.dir";
    public static final String EXECUTION_SAVEPOINT_PATH = "execution.savepoint.path";
    public static final String FLINK_CHECKPOINT_DIR = "flink.checkpoint.dir";
    public static final String FLINK_CHECKPOINT_INTERVAL = "flink.checkpoint.interval";
    public static final String FLINK_MYSQL_CDC_SOURCE = "mysql-cdc-source";
    public static final String FLINK_CONFIG_CDC = "config-cdc";
    public static final String FLINK_BATCH_INTEGRITY = "batch-integrity";
    public static final String FLINK_WEBUI_PORT = "flink.webui.port";
    public static final String FLINK_WEBUI_PORT_KEY = "rest.bind-port";


    // rabbitmq
    public static final String RABBITMQ_HOST = "rabbitmq.host";
    public static final String RABBITMQ_PORT = "rabbitmq.port";
    public static final String RABBITMQ_USERNAME = "rabbitmq.username";
    public static final String RABBITMQ_PASSWORD = "rabbitmq.password";
    public static final String RABBITMQ_VIRTUAL_HOST = "rabbitmq.virtualHost";
    public static final String RABBITMQ_QUEUE_NAME = "rabbitmq.queueName";
    public static final String RABBITMQ_MESSAGE_TTL = "rabbitmq.x-message-ttl";


    // kafka
    public static final String KAFKA_BOOTSTRAP_SERVERS = "kafka.bootstrap.servers";
    public static final String KAFKA_GROUP_ID = "kafka.group.id";
    public static final String KAFKA_CONSUMER_TOPICS = "kafka.consumer.topics";


    // influxDB
    public static final String INFLUXDB_WRITE_URL = "influxdb.write.serverURL";
    public static final String INFLUXDB_READ_URL = "influxdb.read.serverURL";
    public static final String INFLUXDB_DATABASE = "influxdb.database";
    public static final String INFLUXDB_USERNAME = "influxdb.username";
    public static final String INFLUXDB_PASSWORD = "influxdb.password";
    public static final String INFLUXDB_TZ = " tz('Asia/Shanghai')";
    public static final String INFLUXDB_SQL_CQ = "CREATE CONTINUOUS QUERY {}_count_1h ON {} RESAMPLE EVERY 1h FOR 2h " +
            "BEGIN SELECT count(v1) as count INTO {}_count FROM {}_raw GROUP BY time(1h), tid END";
    public static final String INFLUXDB_SQL_COUNT = "SELECT count(v1) as count FROM {} WHERE tid = '{}' and " +
            "time >= '{}' and time < '{}' GROUP BY time(1h) tz('Asia/Shanghai')";


    // tdengine
    public static final String TDENGINE_URL = "tdengine.jdbcUrl";


    // Redis
    public static final String REDIS_HOST = "redis.host";
    public static final String REDIS_DB = "redis.db";
    public static final String REDIS_PORT = "redis.port";
    public static final String REDIS_PASSWORD = "redis.password";
    public static final String REDIS_TIMEOUT = "redis.timeout";
    public static final String REDIS_KEY_STATUS_ONLINE = "tgt:status:online";
    public static final String REDIS_KEY_STATUS_WARN = "tgt:status:warn";


    // mysql
    public static final String MYSQL_URL = "mysql.url";
    public static final String MYSQL_USERNAME = "mysql.username";
    public static final String MYSQL_PASSWORD = "mysql.password";
    public static final String MYSQL_DRIVER = "mysql.driver";
    public static final String MYSQL_CDC_TABLES = "mysql.cdc.tables";
    // mysql-upsert使用需要先创建联合主键
    public static final String SQL_UPSERT_DBI = "INSERT INTO data_batch_integrity(target_id, cj_day, batch_id, " +
            "packet_sum_design, packet_sum_receive, integrity, start_time, end_time, create_time) " +
            "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE target_id = VALUES(target_id), " +
            "cj_day = VALUES(cj_day), batch_id = VALUES(batch_id), packet_sum_design = VALUES(packet_sum_design), " +
            "packet_sum_receive = VALUES(packet_sum_receive), integrity = VALUES(integrity), start_time = " +
            "VALUES(start_time), end_time = VALUES(end_time), create_time = VALUES(create_time);";
    public static final String SQL_INSERT_WARN = "INSERT INTO data_warn(data_json, threshold_json, time_o, time_w, " +
            "level, message, project_id, quota_id, target_id, target_type_id, data_value) " +
            "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
    public static final String SQL_QUOTA_CAL = "SELECT cal_type_code, cal_refers, cal_params FROM " +
            "settings_data_quota where cal_type_code is not null";


    // mqtt
    public static final String MQTT_SERVER_URIS = "mqtt.serverURIs";
    public static final String MQTT_USERNAME = "mqtt.username";
    public static final String MQTT_PASSWORD = "mqtt.password";
    public static final String MQTT_TOPIC_DATA = "mqtt.topic.data";
    public static final String MQTT_TOPIC_WARN = "mqtt.topic.warn";


    // DingTalk
    public static final String DING_BASE_PROJECT = "ding.baseProject";
    public static final String DING_BASE_URL = "ding.baseUrl";
    public static final String DING_TOKEN = "ding.token";
    public static final String DING_SECRET = "ding.secret";


    // warn-send
    public static final String WARN_SEND_MQTT = "warn.send.mqtt";
    public static final String WARN_SEND_DING = "warn.send.ding";
    public static final String WARN_SEND_MYSQL = "warn.send.mysql";
    public static final String WARN_SEND_VOICE = "warn.send.voice";
    public static final String WARN_SEND_EMAIL = "warn.send.email";
    public static final String WARN_SEND_MESSAGE = "warn.send.message";

}
